<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue-2.5.js"></script>
</head>
<body>
    <div id="app">
        <ele :list= "list"></ele>
        <button @click='handleClick'>显示列表</button>
    </div>
    <script>
    Vue.component('ele',{
        render:function(createElement){
            if(this.list.length) {
                return createElement('ul',this.list.map(function(item){
                    return createElement('li',item)
                }))
            }else {
                return createElement('p','列表为空')
            }
        },
        props:{
            list:{
                type:Array,
                default:function() {
                    return []
                }
            }
        }
    })
    let app = new Vue({
        el:'#app',
        data:{
            list:[]
        },
        methods: {
            handleClick:function() {
                this.list = [
                    'vue',
                    'js',
                    'java'
                    ]
            }
        },
    })
    </script>
</body>
</html>